// code.js

// 获取应用实例
let app = getApp()

Page({
	onLoad (option) {
		this.type = option.type
		this.setData({type:this.type})

        //创建可重复使用的toast实例，并附加到this上，通过this.wetoast访问
        new app.WeToast()
	},

	onRun () {
		let type = this.type
		this[type + 'Toast']()
	},

	imgToast () {
        this.wetoast.toast({
            img: ''
        })
    },

    titleToast () {
        this.wetoast.toast({
            title: 'WeToast'
        })
    },

    timeToast () {
        this.wetoast.toast({
            title: 'WeToast',
            duration: 5000
        })
    },

    fullToast () {
        this.wetoast.toast({
            img: '',
            title: 'WeToast',
            success (data) {
                console.log(Date.now() + ': success')
            },
            fail (data) {
                console.log(Date.now() + ': fail')
            },
            complete (data) {
                console.log(Date.now() + ': complete')
            }
        })
    },

    back () {
        wx.navigateBack()
    }
})
